]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
viewSelector: Clean up focusTrap in search results
authorFlorian Müllner <fmuellner@gnome.org>
Sat, 10 Mar 2012 00:33:31 +0000 (01:33 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Mon, 20 Aug 2012 18:40:00 +0000 (20:40 +0200)
Rather than relying on implementation details of StWidget's keyboard
navigation to "hide" the focusTrap from arrow key navigation, implement
the desired behavior explicitly in a custom widget.

https://bugzilla.gnome.org/show_bug.cgi?id=663901

js/ui/viewSelector.js

index ae9127dcacc3e36216458797b6cd696f4d9cdb2f..df86dc66f4db136824f29bb4baa1c1855ae36954 100644 (file)
@@ -21,6 +21,19 @@ const Wanda = imports.ui.wanda;
 const WorkspacesView = imports.ui.workspacesView;
 
 
+const FocusTrap = new Lang.Class({
+    Name: 'FocusTrap',
+    Extends: St.Widget,
+
+    vfunc_navigate_focus: function(from, direction) {
+        if (direction == Gtk.DirectionType.TAB_FORWARD ||
+            direction == Gtk.DirectionType.TAB_BACKWARD)
+            return this.parent(from, direction);
+        return false;
+    }
+});
+
+
 const ViewSelector = new Lang.Class({
     Name: 'ViewSelector',
 
@@ -94,17 +107,11 @@ const ViewSelector = new Lang.Class({
 
         // Since the entry isn't inside the results container we install this
         // dummy widget as the last results container child so that we can
-        // include the entry in the keynav tab path...
-        this._focusTrap = new St.Bin({ can_focus: true });
+        // include the entry in the keynav tab path
+        this._focusTrap = new FocusTrap({ can_focus: true });
         this._focusTrap.connect('key-focus-in', Lang.bind(this, function() {
             this._entry.grab_key_focus();
         }));
-        // ... but make it unfocusable using arrow keys keynav by making its
-        // bounding box always contain the possible focus source's bounding
-        // box since StWidget's keynav logic won't ever select it as a target
-        // in that case.
-        this._focusTrap.add_constraint(new Clutter.BindConstraint({ source: this._searchResults.actor,
-                                                                    coordinate: Clutter.BindCoordinate.ALL }));
         this._searchResults.actor.add_actor(this._focusTrap);
 
         global.focus_manager.add_group(this._searchResults.actor);